﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Strom.Core.Characters;

namespace Strom.Core.Database
{
    public class CharactersManager
    {
        private readonly BinaryDatabase _database;

        public CharactersManager(BinaryDatabase database)
        {
            _database = database;
        }

        public bool CharacterExists(string name)
        {
            lock (_database.CharactersList)
                return !_database.CharactersList.TrueForAll(current => current.Name != name);
        }

        public void CreateCharacter(Network.BaseClient client, string name)
        {
            var newChar = new Character(name, new CharacterStats(1, 50, 50), new CharacterGraphics(), client.CurrentAccount.Infos.Login);

            lock(_database.CharactersList)
            {
                _database.CharactersList.Add(newChar);
                client.CurrentAccount.Characters.Add(newChar);
            }
        }
    }
}
